# Copyright (c) [2020] [蒋奕成]. You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2 THIS SOFTWARE IS PROVIDED ON AN "AS
# IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details.
from datetime import time

from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship

Base = declarative_base()


class wdays(Base):
    __tablename__ = 'wdays'
    id = Column(INTEGER, primary_key=True, autoincrement=True)
    isoweek = Column(INTEGER, nullable=False)
    enable = Column(BOOLEAN, nullable=False, default=True)
    begin = Column(TIME, nullable=False, default=time(hour=7, minute=30, second=0))
    end = Column(TIME, nullable=False, default=time(hour=16, minute=0, second=0))
    lessons = relationship('lessons')


class lessons(Base):
    __tablename__ = 'lessons'
    id = Column(INTEGER, primary_key=True, autoincrement=True)
    enable = Column(BOOLEAN, nullable=False, default=True)
    time = Column(TIME, nullable=False, default=time(hour=7, minute=30, second=0))
    week = Column(INTEGER, ForeignKey('wdays.id'))
